<script>
 import Vue from "vue";
 const blocks = require.context("./", true, /vueBlock.js$/);
 let idMap = {};
 let newMap = {};
 blocks.keys().forEach(async(key) => {
     console.log('key--------', key)
     let blockPrarentName = key.split("/")[1];
     let itemBlock = {};
     idMap = {
         ...blocks(key).default,
     };
     (function(name,data){
         for (var [k, v] of Object.entries(data)) {
             itemBlock[`${name}-${k}`] = v;
             newMap = { ...newMap, ...itemBlock };
         }
     })(blockPrarentName,idMap)
 });

 // todo may be has a prop "config" or "data"
 export default {
     props: {
         name: {
             type: [String, Number],
             required: true,
         },
         routerParams: {
             type: Object,
             default() {
                 return {};
             },
         },
         setting: {
             type: [Object, Array],
             default() {
                 return {};
             },
         },
     },
     render(h) {
         const block = newMap[this.name];// name等于 modules目录下 block父级文件夹名称加"-"加block的name
         if (block) {
             return h(block, {
                 on: this.$listeners,
                 attrs: this.$attrs,
                 scopedSlots: this.$sensorsopedSlots,
                 props: this.$props,
             });
         }
         if (Vue.config.productionTip) {
             return h("div", [`unrecongnized block "${this.name}"`]);
         }
         return null;
     },
 };
 </script>
